package com.security;

import com.config.ContextUtils;
import com.config.ModelMapValue;
import com.utils.CommonUtils;
import freemarker.template.Configuration;
import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Xiongx
 * @version 1.0
 * @date 2021/5/12 9:22
 * @since JDK 1.8
 *
 * 安全框架
 */
@Aspect
@Component
@Order(4)
@Slf4j
public class SecurityAop {

    @Pointcut("@annotation(com.security.Security)")
    private void pointCut(){};

    @Around("pointCut()")
    public Object aroundJobConfig(ProceedingJoinPoint point) throws Throwable{
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletResponse response=attributes.getResponse();
        Object result=null;
        try {
            Class<?> cls=point.getTarget().getClass();
            String method=point.getSignature().getName();
            Method method1= CommonUtils.getMethod(method,cls);

        }catch (Exception e){
            log.info("出现异常");
        }
        return result;
    }
}
